package com.leetcodecn.progrems;

import java.util.Arrays;

public class TwoSum_001 {
    public static void main(String[] args) {
        //用例一
        int[] arr;
        arr = new int[]{3,3,6};
        int target = 9;

        //用例二
        int[] res;
        res = twoSum(arr, target);
        System.out.println(Arrays.toString(res));

        int[] arr2;
        arr2 = new int[]{4,2,6};
        int target2 = 6;
        res = twoSum(arr2, target2);
        System.out.println(Arrays.toString(res));
    }
    public static int[] twoSum(int[] nums, int target) {
        int[] res = new int[2];
        int a;
        int b = 0;
        for (int i = 0; i < nums.length; i++) {
            a = nums[i];
            for (int j = i + 1; j < nums.length; j++) {
                b = a + nums[j];
                if (b == target) {
                    res[0] = i;
                    res[1] = j;
                    return res;
                }
            }
        }
        return res;
    }

}
